package com.ccut;

import javax.swing.*;
import java.util.ArrayList;
import java.util.List;

public class ShapeList extends JComponent {

    private static List<MyShape> myShapeList = new ArrayList<>();

    public ShapeList() {
    }

    public void addShape(MyShape myShape) {
        myShapeList.add(myShape);
        System.out.println("添加了一个图形：\n" + myShape);
    }

    public void showShapeTotalParameter() {
        double totalParameter = 0;
        for (MyShape myShape : myShapeList) {
            totalParameter += myShape.getPerimeter();
        }
        System.out.println("所有图形的周长和为：" + totalParameter);
    }

    public void showShapeTotalArea() {
        double totalArea = 0;
        for (MyShape myShape : myShapeList) {
            totalArea += myShape.getArea();
        }
        System.out.println("所有图形的面积和为：" + totalArea);
    }

    public void showShapeInfo() {
        for (MyShape myShape : myShapeList) {
            System.out.println(myShape);
            System.out.println();
        }
    }

    public void showShape() {
        for (MyShape myShape : myShapeList) {
            myShape.showShape();
        }
    }

    public List<MyShape> getMyShapeList() {
        return myShapeList;
    }
    public void setMyShapeList(List<MyShape> myShapeList) {
        ShapeList.myShapeList = myShapeList;
    }
}
